package HomeWork3;

import java.util.*;
import java.util.function.BiConsumer;

public class homeWorkTest {
    public static void main(String[] args) {
        Worker worker1 = new Worker();
        int[] arr = null;
        System.out.println(Worker.toString(arr));
        int[] arr1 = new int[0];
        System.out.println(Worker.toString(arr1));
        int[] arr2 = {1,2,3,4,5};
        System.out.println(Worker.toString(arr2));
        System.out.println("--------------------------------------------------------");
        List<Worker> list = new ArrayList<>();
        list.add(new Worker(18,"凤姐",20000));
        list.add(new Worker(60,"欧阳峰",8000 ));
        list.add(new Worker(40 ,"刘德华",30000 ));

        list.add(1,new Worker(35,"张柏芝",3300 ));

        list.remove(3);
        for (Worker worker : list) {
            System.out.println(worker);
        }
        Iterator<Worker> iterator = list.iterator();
        while (iterator.hasNext()){
            iterator.next().work();
        }
        System.out.println("--------------------------------------------------------");


        Map<Student,String> map = new HashMap<>();
        map.put(new Student("小明",11),"中国");
        map.put(new Student("小李",14),"美国");

        Set<Map.Entry<Student, String>> entries = map.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"::"+value);
        }
        System.out.println("--------------------------------------------------------");
        for (Student key : map.keySet()) {
            String value = map.get(key);
            System.out.println(key+"::"+value);
        }
        System.out.println("--------------------------------------------------------");
        Iterator<Map.Entry<Student, String>> iterator1 = map.entrySet().iterator();
        while(iterator1.hasNext()){
            Map.Entry<Student, String> next = iterator1.next();
            System.out.println(next.getKey()+"::"+next.getValue());
        }
        System.out.println("--------------------------------------------------------");
        map.forEach(new BiConsumer<Student, String>() {
            @Override
            public void accept(Student student, String s) {
                System.out.println(student+"::"+s);
            }
        });


    }
}
